package org.grayrabbit.cms.util;

import java.text.DecimalFormat;

public class DoubleUtil {
	/**  格式化double 	  
	 * @return
	 */
	public static double formatDouble(double d,int n) {
		StringBuffer sb = new StringBuffer();
		sb.append("#.");
		if(n<0){
			return d;
		}else {
			for(int i=0;i<n;i++) 
				sb.append("#"); 
		} 		
		DecimalFormat df = new DecimalFormat(sb.toString());
		
		String s  = df.format(d);
		double dd = Double.valueOf(s);
		return dd;
	}
 
}
